//
//  CGUINavigationController.swift
//  wisdomstudy
//
//  Created by ggx on 2017/8/3.
//  Copyright © 2017年 高广校. All rights reserved.
//

import UIKit

class CGUINavigationController: UINavigationController, UIGestureRecognizerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.navigationController?.interactivePopGestureRecognizer?.isEnabled = true;//关闭系统自带边缘侧滑
        
        interactivePopGestureRecognizer?.delegate = self
        if #available(iOS 13.0, *) {
            navigationBar.isTranslucent = true
            
            let barAppearance = UINavigationBarAppearance()
//            barAppearance.backgroundColor = KNavBackgroundColor

            navigationBar.standardAppearance = barAppearance;
            navigationBar.scrollEdgeAppearance = navigationBar.standardAppearance
            
        } else {
            // Fallback on earlier versions
//            navigationBar.backgroundColor = .hex(0x5AAAFC)
            navigationBar.setBackgroundImage(UIImage(color: .hex(0x5AAAFC)), for: .default)
        };
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}

extension CGUINavigationController : UINavigationControllerDelegate {
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if viewControllers.count > 0 {
            viewController.hidesBottomBarWhenPushed = true
        }
        super.pushViewController(viewController, animated: animated)
    }
    
    override func popViewController(animated: Bool) -> UIViewController? {
        return super.popViewController(animated: animated)
    }
}
